package com.lmk.ms.common.vo.auth;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;
import java.util.Objects;

/**
 * 菜单数据
 *
 * @author laomake
 * @email laomake@hotmail.com
 */
@Data
@Schema(description = "菜单数据")
public class MenuVO implements Comparable<MenuVO> {

    @Schema(description = "菜单ID")
    private Integer id;

    @Schema(description = "上级菜单ID")
    private Integer pid;

    @Schema(description = "名称")
    private String title;

    @Schema(description = "代码")
    private String code;

    @Schema(description = "图标")
    private String icon;

    @Schema(description = "链接地址")
    private String url;

    @Schema(description = "排序")
    private Integer sq;

    @Schema(description = "是否显示")
    private boolean show;

    private List<MenuVO> children;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MenuVO that = (MenuVO) o;
        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public int compareTo(MenuVO o) {
        return o.getSq() - this.getSq();
    }
}
